package twentyOne;

import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * 后台线程
 *
 * @author MSI PC
 * @since 2020-04-26 13:47
 */
public class demoDeamonThread {

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(()->{

                try {
                    while(true){
                        System.out.println("I'm deamon Thread !");
                        TimeUnit.SECONDS.sleep(5);
                        Map map=Thread.getAllStackTraces();
                        System.out.println(map.size());
                    }

                } catch (InterruptedException e) {
                    e.printStackTrace();
                } finally {
                    System.out.println("finally ");
                }


        });

//        thread.setDaemon(true);
        thread.start();
        Map map=Thread.getAllStackTraces();
        System.out.println("main"+ map.size());
        System.out.println("i'm main thread ");
//        TimeUnit.SECONDS.sleep(6);

    }
}